﻿using System.Reflection;

namespace Basmus.Values
{
    public abstract class PropertyInfoBuilderBase<T> : IBuilder<T>
    {
        private readonly IPropertyInfoBuilder _propertyInfoBuilder;

        protected PropertyInfoBuilderBase(IPropertyInfoBuilder propertyInfoBuilder)
        {
            _propertyInfoBuilder = propertyInfoBuilder;
        }

        public T Build(ValuesContext valuesContext)
        {
            var propertyInfo = _propertyInfoBuilder.Build(valuesContext);
            var target = Build(valuesContext, propertyInfo);
            return target;
        }

        protected abstract T Build(ValuesContext valuesContext, PropertyInfo propertyInfo);

    }
}